//
//  TaskGuiJiAnnotationView.m
//  LogisticsSupplier
//
//  Created by 吕晶 on 2021/4/8.
//  Copyright © 2021 吕晶. All rights reserved.
//

#import "TaskGuiJiAnnotationView.h"

@interface TaskGuiJiAnnotationView ()

@property (nonatomic, strong) UIImageView *iconImgView;

@end

@implementation TaskGuiJiAnnotationView

#ifdef USE_SYSTHESIZE
@synthesize annotation = _annotation; //不会使用父类的set方法 在 setAnnotation方法里 要明确表明 _annotation = annotation;
#else
@dynamic annotation; //用@dynamic后 get 和 set 方法应该获取到的是父类类型的 annotation
#endif

- (instancetype)initWithAnnotation:(id<MAAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        //大头针的图片
        self.iconImgView = [[UIImageView alloc] init];
        [self addSubview:self.iconImgView];
    }
    return self;
}

#ifdef USE_SYSTHESIZE
#pragma mark 当给大头针视图设置大头针模型时可以在此根据模型设置视图内容 @synthesize annotation = _annotation;
-(void)setAnnotation:(TaskGuiJiAnnotation *)annotation{
    _annotation = annotation;
}
#else

-(void)setAnnotation:(TaskGuiJiAnnotation *)annotation{
    [super setAnnotation:annotation];
    if (annotation.type == 1) {
        //起点
        self.iconImgView.image = [UIImage imageNamed:@"icon_qi"];
        self.iconImgView.frame = CGRectMake(-12, -35, 24, 35);
    }else if (annotation.type == 2) {
        //终点
        self.iconImgView.image = [UIImage imageNamed:@"icon_zhong"];
        self.iconImgView.frame = CGRectMake(-12, -35, 24, 35);
    }else if (annotation.type == 3) {
        //途经点
        self.iconImgView.image = [UIImage imageNamed:@"icon_driver_location"];
        self.iconImgView.frame = CGRectMake(-48, -68, 96, 68);
    }
}

#endif

@end
